package org.lanqiao.demo;

import java.util.*;
import java.util.Map.Entry;

public class Test02 {
	public static void main(String[] args) {
		test01();
	}
	
	public static void test01() {
		Map map0 = new HashMap();
		
		map0.put("zhangsan", 20);
		map0.put("lisi", 21);
		map0.put("wangwu", 22);
		
		Set setKeys = map0.keySet();
		//先取出key的set集合或者Entry的set集合，然后再对其进行遍历
		//遍历元素进行输出
		System.out.println("增强型的for循环遍历Map：");
		for (Object obj : setKeys) {
			System.out.println(obj + "-" + map0.get(obj));
		}
		
		Iterator it = setKeys.iterator();
//		while(it.hasNext()) {
//			System.out.println();
//		}
		
		Set EntryKeys = map0.entrySet();
		System.out.println("增强型的for循环遍历Map：");
		for (Object obj : EntryKeys) {
			Entry en = (Entry)obj;
			System.out.println(en.getKey() + "-" + en.getValue());
		}
	}
}
